<template>
	<div>
		<el-input type="textarea" :rows="23" v-model="landinText">
		</el-input>
		<el-row>
			<el-button type="success" @click="submit()" plain>提交更改</el-button>
		</el-row>
</div>
</template>

<script>
	export default {
		data() {
			return {
				landinText: '',
				landinInfo:''
			}
		},
		methods: {
			// 提交修改
			submit() {
				let cnt = {
					fileContent: this.landinText,
					channelCode: this.landinInfo.channelCode,
					landinCode: this.landinInfo.landinCode,
					ver: this.landinInfo.ver
				}
				this.$api.writeFile(cnt, (res) => {
					if (res.data.rc == this.$util.RC.SUCCESS) {
						this.$message({
							type: 'success',
							message: '落地页修改成功!'
						});
						this.$router.push({
							path: '/landinList',
							name: 'landinList',
						})
					}
				})
			},
			// 读取文件
			readFile(cnt) {
				this.$api.readFile(cnt, (res) => {
					if (res.data.rc == this.$util.RC.SUCCESS) {
						this.landinText = this.$util.tryParseJson(res.data.c)
					}
				})
			}
		},
		mounted() {
			this.landinInfo = this.$route.params.info
			let cnt = {
				channelCode: this.landinInfo.channelCode,
				landinCode: this.landinInfo.landinCode,
				ver: this.landinInfo.ver
			}
			this.readFile(cnt)
			console.log(this.landinInfo)
		}
	}
</script>

<style>
</style>
